//
//  MYGMicrosrationApi.swift
//  MYDoctor
//
//  Created by 小火科技 on 2024/4/15.
//

import UIKit
import Moya

enum MYGMicrosrationApi {
    case getDoctorInfo(from_doctor_id:String)//医生详情
    case getDoctorMicro(type:Int,doctor_id:String) //医生动态
    case aboutDoctor(type:Int,doctor_id:String) //关于医生 type 0 全部 1我的介绍 2专业擅长 3临床实验
    case delPersonMico(id:Int) //删除动态
    case clinical_experiments(params:[String:Any])
    case get_doctor_phone_info(phone:String) //根据手机号获取医生详情
}

extension MYGMicrosrationApi: MYGTargetType {

    var params: [String : Any] {
        var params: [String: Any] = [:]
        switch self {
        case let .getDoctorInfo( from_doctor_id):
            params["from_doctor_id"] = from_doctor_id
        case let .getDoctorMicro(type,doctor_id):
            params["type"] = type
            params["doctor_id"] = doctor_id
            params["page"] = 1
            params["pageSize"] = 1000
        case let .aboutDoctor(type,doctor_id):
            params["type"] = type
            params["doctor_id"] = doctor_id
        case .delPersonMico:
            break
        case let .clinical_experiments(params):
            return params
        case let .get_doctor_phone_info(phone):
            params["phone"] = phone
        }
        return params
    }
    
    var path: String {
        switch self {
        case .getDoctorInfo:
            "/api/micro/doctor"
        case .getDoctorMicro:
            "/api/micro/my_posts"
        case .aboutDoctor:
            "/api/doctor/personal"
        case .delPersonMico(let id):
            "/api/micro/posts/\(id)"
        case .clinical_experiments:
            "/api/micro/clinical_experiments"
        case .get_doctor_phone_info:
            "/api/passport/get_doctor_phone_info"
        }
    }
    var baseURL: URL {
        switch self {
        case .getDoctorInfo, .getDoctorMicro , .aboutDoctor,.delPersonMico, .clinical_experiments,.get_doctor_phone_info:
            return  URL(string: BaseUrl)!
        }
    } 

    var method: Moya.Method {
        switch self {
        case .getDoctorInfo:
            .post
        case .getDoctorMicro,.clinical_experiments,.get_doctor_phone_info:
            .get
        case .aboutDoctor:
            .get
        case .delPersonMico:
            .delete
        }
    }
}
